/**
 * 
 */
package com.xbang.attendance.web.action.system.sign;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.demo2do.lighturl.annotation.Action;
import com.xbang.attendance.entity.Sign.Actioninfo;
import com.xbang.attendance.service.SystemService;
import com.xbang.core.page.Result;
import com.xbang.core.struts.support.SearchActionSupport;

/**
 * @author dev.zhang
 * 
 */
public class Search extends SearchActionSupport {

	private static final long serialVersionUID = 5656801837372877856L;

	@Autowired
	private SystemService systemService;

	private List<Actioninfo> actioninfos=new ArrayList<Actioninfo>();

	public List<Actioninfo> getActioninfo() {
		return actioninfos;
	}

	public void setActioninfo(List<Actioninfo> actioninfo) {
		this.actioninfos = actioninfo;
	}

	public String execute() throws Exception {
		return "search";
	}

	@Action("/system/sign/search/do")
	public String doSearch() throws Exception {
		 Map map=new HashMap();
//		if(!searchComponent.getParameters().isEmpty()){
//			if(searchComponent.getParameters().get("eqActioninfoId")!=null){
//			int i = Integer.valueOf(searchComponent.getParameters().get("eqActioninfoId").toString());
//			map.put("eqActioninfoId", i);
//			}
//			searchComponent.setParameters(map);
//		
//		}
		 if(!searchComponent.getParameters().isEmpty()){
				if(searchComponent.getParameters().get("likeActioninfoUserId")!=null){
					String s = searchComponent.getParameters().get("likeActioninfoUserId").toString();
					String sql = "select userId from userinfo where userName like '"+s+"'";
					//更新数据之前treport表中的最大月份
					List<Map> n = systemService.queryForList(sql, map);
					for(Map map1 : n){
						String s1 =  map1.get("userId").toString();
						map.put("likeActioninfoUserId", s1);
					}
					searchComponent.setParameters(map);
				}
			
			}


		String hqlSentence = "FROM Actioninfo Actioninfo  WHERE 1 = 1 ";
		Result result = systemService.searchByPage(hqlSentence, searchComponent, page);
		actioninfos = result.getItems();
		page = result.getPage();
		return "index";
	}

	/**
	 * @param systemService
	 */
	public void setSystemService(SystemService systemService) {
		this.systemService = systemService;
	}

	@Override
	public void resetCustomerSearchCriteria() {
		// TODO Auto-generated method stub

	}

}
